*****************************************************************************************************************************************
** Zigerell re-analysis of Schneider and Gonzalez 2021 Personality and Individual Differences
** "Racial resentment predicts eugenics support more robustly than genetic attributions"
** Data are here: https://osf.io/ny364/?view_only=8fb518302fa342a6ac940f4187ec25c1 
*****************************************************************************************************************************************

*****************************************************************************************************************************************
** S1-1
** Correlations of genetic attributions for selected traits
*****************************************************************************************************************************************

pwcorr Q3_a_1 Q5_a_1 Q6_a_1 Q8_a_1 Q10_a_1 Q1_a_1 Q4_a_1 Q14_a_1
matrix list r(C), format(%9.2f)
desc   Q3_a_1 Q5_a_1 Q6_a_1 Q8_a_1 Q10_a_1 Q1_a_1 Q4_a_1 Q14_a_1
pwcorr Q3_a_1 Q5_a_1 Q6_a_1 Q8_a_1 Q10_a_1 Q1_a_1 Q4_a_1 Q14_a_1, obs

*****************************************************************************************************************************************
** S2-1
** Correlations of eugenics outcomes with genetic attributions 
*****************************************************************************************************************************************

// Recode eugenics outcomes from 0 to 1, with higher values indicating more support

codebook gen1 gen2 gen3 gen4

gen gen01 = (5 - gen1)/4
gen gen02 = (5 - gen2)/4
gen gen03 = (5 - gen3)/4
gen gen04 = (5 - gen4)/4

tab gen1 gen01, mi
tab gen2 gen02, mi
tab gen3 gen03, mi
tab gen4 gen04, mi

// Correlations

pwcorr gen01 Q1_a_1 Q2_a_1 Q3_a_1 Q4_a_1 Q5_a_1 Q6_a_1 Q7_a_1 Q8_a_1 Q9_a_1 Q10_a_1 Q11_a_1 Q12_a_1 Q13_a_1 Q14_a_1 obe_8_1_1
matrix list r(C), format(%9.2f)
pwcorr gen02 Q1_a_1 Q2_a_1 Q3_a_1 Q4_a_1 Q5_a_1 Q6_a_1 Q7_a_1 Q8_a_1 Q9_a_1 Q10_a_1 Q11_a_1 Q12_a_1 Q13_a_1 Q14_a_1 obe_8_1_1
matrix list r(C), format(%9.2f)
pwcorr gen03 Q1_a_1 Q2_a_1 Q3_a_1 Q4_a_1 Q5_a_1 Q6_a_1 Q7_a_1 Q8_a_1 Q9_a_1 Q10_a_1 Q11_a_1 Q12_a_1 Q13_a_1 Q14_a_1 obe_8_1_1
matrix list r(C), format(%9.2f)
pwcorr gen04 Q1_a_1 Q2_a_1 Q3_a_1 Q4_a_1 Q5_a_1 Q6_a_1 Q7_a_1 Q8_a_1 Q9_a_1 Q10_a_1 Q11_a_1 Q12_a_1 Q13_a_1 Q14_a_1 obe_8_1_1
matrix list r(C), format(%9.2f)

pwcorr gen01 Q1_a_1 Q2_a_1 Q3_a_1 Q4_a_1 Q5_a_1 Q6_a_1 Q7_a_1 Q8_a_1 Q9_a_1 Q10_a_1 Q11_a_1 Q12_a_1 Q13_a_1 Q14_a_1 obe_8_1_1, obs
pwcorr gen02 Q1_a_1 Q2_a_1 Q3_a_1 Q4_a_1 Q5_a_1 Q6_a_1 Q7_a_1 Q8_a_1 Q9_a_1 Q10_a_1 Q11_a_1 Q12_a_1 Q13_a_1 Q14_a_1 obe_8_1_1, obs
pwcorr gen03 Q1_a_1 Q2_a_1 Q3_a_1 Q4_a_1 Q5_a_1 Q6_a_1 Q7_a_1 Q8_a_1 Q9_a_1 Q10_a_1 Q11_a_1 Q12_a_1 Q13_a_1 Q14_a_1 obe_8_1_1, obs
pwcorr gen04 Q1_a_1 Q2_a_1 Q3_a_1 Q4_a_1 Q5_a_1 Q6_a_1 Q7_a_1 Q8_a_1 Q9_a_1 Q10_a_1 Q11_a_1 Q12_a_1 Q13_a_1 Q14_a_1 obe_8_1_1, obs

*****************************************************************************************************************************************
** S3-1
** Factor analysis of Schneider and Gonzalez 2021 trait aggregate measures
*****************************************************************************************************************************************

codebook Q3_a_1 Q8_a_1 Q10_a_1 Q5_a_1 Q6_a_1
desc     Q3_a_1 Q8_a_1 Q10_a_1 Q5_a_1 Q6_a_1

factor   Q3_a_1 Q8_a_1 Q10_a_1 Q5_a_1 Q6_a_1, pcf  
rotate

factor   Q3_a_1 Q8_a_1 Q10_a_1 Q5_a_1 Q6_a_1 if race==1, pcf // Limited to White respondents
rotate

factor   Q3_a_1 Q8_a_1 Q10_a_1 Q5_a_1 Q6_a_1 if race!=1, pcf // Limited to nonWhite respondents
rotate

*****************************************************************************************************************************************
** S4-1
** Factor analysis of Schneider and Gonzalez 2021 trait aggregate measures
*****************************************************************************************************************************************

// SG21 trait aggregate measure [genetic attributions]

egen sg21a = rowmean (Q3_a_1 Q8_a_1 Q10_a_1 Q5_a_1 Q6_a_1)
sum  sg21a 
egen sg21a_std = std(sg21a)
sum  sg21a_std

// SG21 trait aggregate measure [personal/free will attributions]

egen sg21c = rowmean (Q3_c_1 Q8_c_1 Q10_c_1 Q5_c_1 Q6_c_1)
sum  sg21c 
egen sg21c_std = std(sg21c)
sum  sg21c_std

// Controls

tab gender

tab race
recode race (4/10=4), gen(race4)
tab race race4, mi

tab educ

sum birthyr
gen age = 2015 - birthyr
sum age
recode age (18/21=1) (22/29=2) (30/39=3) (40/49=4) (50/59=5) (60/69=6) (70/79=7) (80/100=8), gen(ageGRP)
label define ageGRP 1 "[1] 18/21" 2 "[2] 22/29" 3 "[3] 30/39" 4 "[4] 40/49" 5 "[5] 50/59" 6 "[6] 60/69" 7 "[7] 70/79" 8 "[8] 80+"
label values ageGRP ageGRP
tab ageGRP, mi

tab faminc
tab faminc, nol
recode faminc (12/31=12), gen(hhincMISS)
tab hhincMISS

tab pew_churatd

tab ideo5 

tab pid7

factor RI1 RI2 RI3 RI4 RI5 RI6, pcf
rotate
predict rr_factor
tab RI1, nol
gen RI1_rev = 6 - RI1
gen RI3_rev = 6 - RI3
gen RI6_rev = 6 - RI6
sum    RI1_rev RI2 RI3_rev RI4 RI5 RI6_rev
pwcorr RI1_rev RI2 RI3_rev RI4 RI5 RI6_rev
egen    rr = rowmean(RI1_rev RI2 RI3_rev RI4 RI5 RI6_rev)
sum     rr
pwcorr  rr_factor rr
tabstat rr, by(ideo5)
egen    rr_std = std(rr)
sum     rr_std

// Analyses

svyset [pw=weight]

set cformat %9.3f

svy: reg gen01 i.gender i.race4 i.educ i.ageGRP i.hhincMISS i.pew_churatd i.ideo5 i.pid7 rr_std sg21c_std sg21a_std 
svy: reg gen02 i.gender i.race4 i.educ i.ageGRP i.hhincMISS i.pew_churatd i.ideo5 i.pid7 rr_std sg21c_std sg21a_std 
svy: reg gen03 i.gender i.race4 i.educ i.ageGRP i.hhincMISS i.pew_churatd i.ideo5 i.pid7 rr_std sg21c_std sg21a_std 
svy: reg gen04 i.gender i.race4 i.educ i.ageGRP i.hhincMISS i.pew_churatd i.ideo5 i.pid7 rr_std sg21c_std sg21a_std 

svy: reg gen01 i.gender i.race4 i.educ i.ageGRP i.hhincMISS i.pew_churatd i.ideo5 i.pid7 rr_std           sg21a_std 
svy: reg gen02 i.gender i.race4 i.educ i.ageGRP i.hhincMISS i.pew_churatd i.ideo5 i.pid7 rr_std           sg21a_std 
svy: reg gen03 i.gender i.race4 i.educ i.ageGRP i.hhincMISS i.pew_churatd i.ideo5 i.pid7 rr_std           sg21a_std 
svy: reg gen04 i.gender i.race4 i.educ i.ageGRP i.hhincMISS i.pew_churatd i.ideo5 i.pid7 rr_std           sg21a_std 

*****************************************************************************************************************************************
** S5-1
** Multipolar racial attitudes
*****************************************************************************************************************************************

// Stereotype measures

tab1 Q17 Q15
desc Q17 Q15
gen wbCRIME  = Q17 - Q15

tab1 Q22 Q20
desc Q22 Q20
gen wbINTEL  = Q22 - Q20

tab1 Q27 Q25
desc Q27 Q25
gen wbATHLE  = Q27 - Q25

tab1 Q32 Q30
desc Q32 Q30
gen wbDRUGS  = Q32 - Q30

tab1 Q37 Q35
desc Q37 Q35
gen wbCONSC  = Q37 - Q35

sum wbCRIME wbINTEL wbATHLE wbDRUGS wbCONSC

recode wbCRIME (-100/-1=1) (0=2) (1/100=3), gen(wbCRIME3)
recode wbINTEL (-100/-1=1) (0=2) (1/100=3), gen(wbINTEL3)
recode wbATHLE (-100/-1=1) (0=2) (1/100=3), gen(wbATHLE3)
recode wbDRUGS (-100/-1=1) (0=2) (1/100=3), gen(wbDRUGS3)
recode wbCONSC (-100/-1=1) (0=2) (1/100=3), gen(wbCONSC3)

label define wb 1 "[1] Blacks > Whites" 2 "[2] Whites = Blacks" 3 "[3] Whites > Blacks"
label values wbCRIME3 wbINTEL3 wbATHLE3 wbDRUGS3 wbCONSC3 wb

tab1   wbCRIME3 wbINTEL3 wbATHLE3 wbDRUGS3 wbCONSC3
pwcorr wbCRIME3 wbINTEL3 wbATHLE3 wbDRUGS3 wbCONSC3

svyset [pw=weight]

svy: prop wbCRIME3 
svy: prop wbINTEL3
svy: prop wbATHLE3
svy: prop wbDRUGS3
svy: prop wbCONSC3

// Analyses

svyset [pw=weight]

set cformat 

svy: reg gen01 i.gender i.race4 i.educ i.ageGRP i.hhincMISS i.pew_churatd i.ideo5 i.pid7 Q5_a_1 ib2.wbINTEL3
margins, atmeans at(wbINTEL3=(1(1)3)) level(83.4) noatlegend
svy: reg gen02 i.gender i.race4 i.educ i.ageGRP i.hhincMISS i.pew_churatd i.ideo5 i.pid7 Q5_a_1 ib2.wbINTEL3
margins, atmeans at(wbINTEL3=(1(1)3)) level(83.4) noatlegend
svy: reg gen03 i.gender i.race4 i.educ i.ageGRP i.hhincMISS i.pew_churatd i.ideo5 i.pid7 Q5_a_1 ib2.wbINTEL3
margins, atmeans at(wbINTEL3=(1(1)3)) level(83.4) noatlegend
svy: reg gen04 i.gender i.race4 i.educ i.ageGRP i.hhincMISS i.pew_churatd i.ideo5 i.pid7 Q5_a_1 ib2.wbINTEL3
margins, atmeans at(wbINTEL3=(1(1)3)) level(83.4) noatlegend

*****************************************************************************************************************************************
** S6-1
** Racial resentment quartiles
*****************************************************************************************************************************************

tab rr
xtile rr4 = rr, nq(4)
tab rr4
tab rr if rr4==1
tab rr if rr4==2
tab rr if rr4==3
tab rr if rr4==4

svy: reg gen01 i.gender i.race4 i.educ i.ageGRP i.hhincMISS i.pew_churatd i.ideo5 i.pid7 Q5_a_1 ib1.rr4
margins, atmeans at(rr4=(1(1)4)) level(83.4) noatlegend
svy: reg gen02 i.gender i.race4 i.educ i.ageGRP i.hhincMISS i.pew_churatd i.ideo5 i.pid7 Q5_a_1 ib1.rr4
margins, atmeans at(rr4=(1(1)4)) level(83.4) noatlegend
svy: reg gen03 i.gender i.race4 i.educ i.ageGRP i.hhincMISS i.pew_churatd i.ideo5 i.pid7 Q5_a_1 ib1.rr4
margins, atmeans at(rr4=(1(1)4)) level(83.4) noatlegend
svy: reg gen04 i.gender i.race4 i.educ i.ageGRP i.hhincMISS i.pew_churatd i.ideo5 i.pid7 Q5_a_1 ib1.rr4
margins, atmeans at(rr4=(1(1)4)) level(83.4) noatlegend

*****************************************************************************************************************************************
** Figure 1
*****************************************************************************************************************************************

svyset [pw=weight]

pwcorr wbINTEL3 wbCONSC3 wbCRIME3 wbDRUGS3 wbATHLE3

desc Q3_a_1 Q5_a_1 Q6_a_1 Q8_a_1 Q10_a_1
tab1 wbDRUGS3 wbINTEL3 wbATHLE3 wbCONSC3 wbCRIME3

codebook Q34_a_1 Q3_a_1
svy: reg Q34_a_1 i.gender i.race4 i.educ i.ageGRP Q3_a_1 ib2.wbDRUGS3
margins, atmeans at(wbDRUGS3=(1 2 3)) level(83.4) noatlegend

codebook Q24_a_1 Q5_a_1
svy: reg Q24_a_1 i.gender i.race4 i.educ i.ageGRP Q5_a_1 ib2.wbINTEL3
margins, atmeans at(wbINTEL3=(1 2 3)) level(83.4) noatlegend

codebook Q29_1_1 Q6_a_1
svy: reg Q29_1_1 i.gender i.race4 i.educ i.ageGRP Q6_a_1 ib2.wbATHLE3
margins, atmeans at(wbATHLE3=(1 2 3)) level(83.4) noatlegend

codebook Q39_a_1 Q8_a_1
svy: reg Q39_a_1 i.gender i.race4 i.educ i.ageGRP Q8_a_1 ib2.wbCONSC3
margins, atmeans at(wbCONSC3=(1 2 3)) level(83.4) noatlegend

codebook Q19_a_1 Q10_a_1
svy: reg Q19_a_1 i.gender i.race4 i.educ i.ageGRP Q10_a_1 ib2.wbCRIME3
margins, atmeans at(wbCRIME3=(1 2 3)) level(83.4) noatlegend

*****************************************************************************************************************************************
** Controls
*****************************************************************************************************************************************

tab1 gender race4 educ ageGRP hhincMISS pew_churatd ideo5 pid7
tab  race race4
tab  age ageGRP
tab  faminc hhincMISS
